package cn.iocoder.yudao.module.order.dal.mysql.tradeorder;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.order.dal.dataobject.tradeorder.TradeOrderDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.order.controller.admin.tradeorder.vo.*;

/**
 * 交易订单 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {

    default PageResult<TradeOrderDO> selectPage(TradeOrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TradeOrderDO>()
                .eqIfPresent(TradeOrderDO::getOrderNumber, reqVO.getOrderNumber())
                .likeIfPresent(TradeOrderDO::getStoreName, reqVO.getStoreName())
                .eqIfPresent(TradeOrderDO::getBusinessScene, reqVO.getBusinessScene())
                .eqIfPresent(TradeOrderDO::getOperatorMember, reqVO.getOperatorMember())
                .eqIfPresent(TradeOrderDO::getPhoneNumber, reqVO.getPhoneNumber())
                .eqIfPresent(TradeOrderDO::getAmount, reqVO.getAmount())
                .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus())
                .eqIfPresent(TradeOrderDO::getPaymentMethod, reqVO.getPaymentMethod())
                .eqIfPresent(TradeOrderDO::getCreatedAt, reqVO.getCreatedAt())
                .orderByDesc(TradeOrderDO::getId));
    }

    default List<TradeOrderDO> selectList(TradeOrderExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TradeOrderDO>()
                .eqIfPresent(TradeOrderDO::getOrderNumber, reqVO.getOrderNumber())
                .likeIfPresent(TradeOrderDO::getStoreName, reqVO.getStoreName())
                .eqIfPresent(TradeOrderDO::getBusinessScene, reqVO.getBusinessScene())
                .eqIfPresent(TradeOrderDO::getOperatorMember, reqVO.getOperatorMember())
                .eqIfPresent(TradeOrderDO::getPhoneNumber, reqVO.getPhoneNumber())
                .eqIfPresent(TradeOrderDO::getAmount, reqVO.getAmount())
                .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus())
                .eqIfPresent(TradeOrderDO::getPaymentMethod, reqVO.getPaymentMethod())
                .eqIfPresent(TradeOrderDO::getCreatedAt, reqVO.getCreatedAt())
                .orderByDesc(TradeOrderDO::getId));
    }

}
